<?php
  include ('header.php');
?>
<head>
<title><?php echo $titles['site_config']?></title>
</head>

<body>
<?php

if($_SESSION['access']<2)
{
DIE('Помилка: Ви не маєте права доступу до сату:');
}

if ($_GET[del]){
$sql="DELETE FROM admin_config where id='".$_GET[del]."'";  
$process=mysql_query($sql, $db);
}



if (isset($_POST['edit_full_config']) and $_POST['edit_full_config']) {
for ($n = 1; $n <= $_SESSION["count_par"]; $n++) {
$id="id".$n;
$config_name="config_name".$n;
$config_description="config_description".$n;
$config_size="config_size".$n;
$config_value="config_value".$n;
$sql="update admin_config set
config_value='".$_POST[$config_value]."' where  id='".$_POST[$id]."'";
$process=mysql_query($sql, $db);
//echo $sql."<br>";
}

}
?>
<form name="edit_config"  method="POST" action='<?php echo $_SERVER['PHP_SELF']?>' >
<table class="IND_INVENTORY" width=50%>
<tr>
	<td class="IND_INVENTORY_C">№</td>
	<td class="IND_INVENTORY_C">Параметр</td>
	<td class="IND_INVENTORY_C" width=15>Значення</td>
	

</tr>
<?php
$sql="select * from admin_config";  
$process=mysql_query($sql, $db);
$i=1;
$j=0;
while ($row = mysql_fetch_array($process, $i)){
$j++;
	echo "<tr>";
	echo " <td class=\"IND_INVENTORY_C\" ><input type=hidden  name='id".$j."' value='".$row[id]."'>".$row[id]."</td>";
	echo "<td class=\"IND_INVENTORY\">".$row[config_description]."</td>";
	if ($row[config_size]>1){
	echo "<td class=\"IND_INVENTORY\"><input type=text  name='config_value".$j."' value='".$row[config_value]."' size=".$row[config_size]."></td>";
	}
	
	/*
	else 
	{
	if($row[config_value]>0){
	$row[config_value]=1;
	$checked='checked';
	}
	echo "<td class=\"IND_INVENTORY\"><input type=checkbox  ".$checked." name='config_value".$j."' ></td>";	
	}
	*/
	echo "</tr>";
}
$_SESSION["count_par"]=$j;

?>
<tr><td colspan="6" ><input type="submit" value="<?php echo $texts[save] ?>" name="edit_full_config"></td></tr>
</table>

</form>
</body>
<?php
  include ('footer.php');
?>